package io.github.wppli.domain.pay.repository;

import io.github.wppli.domain.pay.event.OrderBehaviorsEvent;
import io.github.wppli.domain.pay.model.aggregates.CreateOrderAggregate;
import io.github.wppli.domain.pay.model.entity.PayOrderEntity;
import io.github.wppli.domain.pay.model.entity.ProductEntity;
import io.github.wppli.domain.pay.model.entity.ShopCartEntity;
import io.github.wppli.domain.pay.model.entity.UnpaidOrderEntity;
import io.github.wppli.types.event.BaseEvent;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 订单仓储接口
 * @author li--jiaqiang 2025−03−19
 */
public interface IOrderRepository {

    /**
     * 查询未支付的订单
     * @param shopCartEntity 购物车实体
     * @return 未支付的订单实体
     */
    UnpaidOrderEntity queryUnpaidOrder(ShopCartEntity shopCartEntity);


    void saveOrder(CreateOrderAggregate aggregate);

    void updateOrderPayInfo(PayOrderEntity payOrderEntity);

    boolean changeOrderPaySuccess(String orderId, String transactionId, BigDecimal totalAmount, Date payTime);

    CreateOrderAggregate queryOrder(String orderId);

    /**
     * 查询待补货订单
     */
    List<String> queryReplenishmentOrder();

    List<String> queryNoPayNotifyOrder();


    /** 查询超时15分钟，未支付订单 */
    List<String> queryTimeoutCloseOrderList();

    boolean changeOrderClose(String orderId);

    List<ProductEntity> queryProductList();

    void sendOrderBehaviorsMessage(String topic, BaseEvent.EventMessage<OrderBehaviorsEvent.OrderBehaviorsEntity> orderBehaviorsEntityEventMessage);

    void saveProductSku(ProductEntity productEntity);

    void createViewOrder(Long productId);

    void createBuyOrder(Long productId, Integer count);
}